const Mock = require('mockjs')
const API_TYPE = {
  WEBSERVICE: 'webService',
  HTTP: 'http'
}
const PDM_API_TYPE = {
  C919: 'C919',
  ARJ21_2: 'ARJ21_2',
  ARJ21_3: 'ARJ21_3',
}
const PDM_API_PLATFORM = {
  IDEAL: 'ideal.comac.cc/Windchill/servlet',
  CPC: 'cpc.comac.cc/Windchill/servlet',
}
const listPagedPart = Mock.mock({
  pdm_api_type: null,
  url: "/pdm/listPagedPart",
  type: API_TYPE.WEBSERVICE,
  params: "?token=xxxxxxxx",
  requestBody: {
    "partNumber": "零件编号, 必填, 可模糊",
    "partName": "零件名称, 非必填, 可模糊",
    "partVersion": "零件版次, 非必填, 可模糊",
    "aircraftType": "机型, 非必填",
    "type": "类型, 非必填",
    "pnFlag": "是否件号, 非必填",
    "state": "状态, 非必填",
    "view": "视图, 非必填",
    "pageSize": "分页大小, 必填",
    "pageNum": "当前分页, 必填"
  },
  responseBody: {
    'data|2-5': [{
      'oid|+1': '1000',
      'partNumber|+1': '13200',
      'partName': Mock.mock(/[A-Z][0-9]{6}/),
      'partVersion': 'v.latest',
      'aircraftType': Mock.Random.boolean() ? 'C919' : "ARJ21",
      'type': Mock.mock(/[A-Z][0-9]/),
      'pnFlag': Mock.Random.boolean(),
      'state': '已发布',
      'view': '',
      'version|+1': '25555',
    }],
    'msg': 'success',
    'paged': {
      total: 100,
      pageNum: 1,
      pageSize: 10
    },
    code: 8000
  }

})

const listPagedPartMPR = Mock.mock({
  pdm_api_type: null,
  url: "/pdm/listPagedPartMPR",
  type: API_TYPE.WEBSERVICE,
  params: "?token=xxxxxxxx",
  requestBody: {
    "partOid": "零件 OID, 必填",
    "mprNumber": "MPR 编号, 非必填, 可模糊",
    "mprVersion": "零件版次, 非必填, 可模糊",
    "mprState": "MPR 状态, 非必填",
    "pageSize": "分页大小, 必填",
    "pageNum": "当前分页, 必填"
  },
  responseBody: {
    'data|2-5': [{
      "mprOid": "MPR_OID",
      "mprNumber": "MPR 编号",
      "mprVersion": "MPR 版本",
      "mprState": "MPR 状态",
      "mprEff": "MPR 有效性",
      "manuDept": "MPR 制造单位",
      "partOid": "零件 OID",
      "partNumber": "零件编号",
      "partVersion": "零件版本",
    }],
    'msg': 'success',
    'paged': {
      total: 100,
      pageNum: 1,
      pageSize: 10
    },
    code: 8000
  }

})
const getPart = Mock.mock({
  pdm_api_type: null,
  url: "/pdm/getPart",
  type: API_TYPE.WEBSERVICE,
  params: "?token=xxxxxxxx",
  requestBody: {
    "partOid": "零件 OID"
  },
  responseBody: {
    'data': {
      "partOid": "零件 OID",
      "partName": "零件名称",
      "version": "零件系统版本",
      "chgltr": "更改字母",
      "state": "零件状态",
      "impPartType": "关重件类型",
      "partEff": "零件有效性",
      "pnFlag": "是否件号",
      "partCode": "零件代码",
      "partNumber": "零件编号",
      "partType": "零件类型"
    },
    'msg': 'success',
    'paged': {
      total: 0,
      pageNum: 1,
      pageSize: 1
    },
    code: 8000
  }
})
const getPart_ex = Mock.mock({
  pdm_api_type: null,
  url: "/pdm/getPart_ex",
  type: API_TYPE.WEBSERVICE,
  params: "?token=xxxxxxxx",
  requestBody: {
    "partOid": "零件 OID",
    "foEff": "fo 有效性"
  },
  responseBody: {
    'data': {
      usedDept: "",
      usedSta: ""
    },
    'msg': 'success',
    'paged': {
      total: 0,
      pageNum: 1,
      pageSize: 1
    },
    code: 8000
  }
})
const getPartMPR = Mock.mock({
  pdm_api_type: null,
  url: "/pdm/getPartMPR",
  type: API_TYPE.WEBSERVICE,
  params: "?token=xxxxxxxx",
  requestBody: {
    "partOid": "零件 MPR_OID"
  },
  responseBody: {
    'data': {
      "partOid": "零件 OID",
      "partNumber": "零件编号",
      "partVersion": "零件系统版本",
      "mprOid": "MPR_OID",
      "mprNumber": "MPR 编号",
      "mprVersion": "MPR 系统版本",
      "mprState": "MPR 状态",
      "mprEff": "MPR 有效性",
      "manuDept": "制造单位",
      "usedDept": "装配工位",
      "usedSta": "装配站位",
      "fabInfo": "制造依据",
    },
    'msg': 'success',
    'paged': {
      total: 0,
      pageNum: 1,
      pageSize: 1
    },
    code: 8000
  }
})
listPagedPart.responseBody.paged.pageSize = listPagedPart.responseBody.data.length
listPagedPart.responseBody.data.forEach(item => {
  item.view = item.pnFlag ? '件号' : '图号'
})
listPagedPartMPR.responseBody.paged.pageSize = listPagedPartMPR.responseBody.data.length

const listPagedPart_C919 = listPagedPart
const listPagedPart_ARJ21_2 = listPagedPart
const listPagedPart_ARJ21_3 = listPagedPart
listPagedPart_C919.pdm_api_type = PDM_API_TYPE.C919
listPagedPart_ARJ21_2.pdm_api_type = PDM_API_TYPE.ARJ21_2
listPagedPart_ARJ21_3.pdm_api_type = PDM_API_TYPE.ARJ21_3

const listPagedPartMPR_C919 = listPagedPartMPR
const listPagedPartMPR_ARJ21_2 = listPagedPartMPR
const listPagedPartMPR_ARJ21_3 = listPagedPartMPR
listPagedPartMPR_C919.pdm_api_type = PDM_API_TYPE.C919
listPagedPartMPR_ARJ21_2.pdm_api_type = PDM_API_TYPE.ARJ21_2
listPagedPartMPR_ARJ21_3.pdm_api_type = PDM_API_TYPE.ARJ21_3

const getPart_C919 = getPart
const getPart_ARJ21_2 = getPart
const getPart_ARJ21_3 = getPart
getPart_C919.pdm_api_type = PDM_API_TYPE.C919
getPart_ARJ21_2.pdm_api_type = PDM_API_TYPE.ARJ21_2
getPart_ARJ21_3.pdm_api_type = PDM_API_TYPE.ARJ21_3

const getPart_ex_C919 = getPart_ex
const getPart_ex_ARJ21_2 = getPart_ex
const getPart_ex_ARJ21_3 = getPart_ex
getPart_ex_C919.pdm_api_type = PDM_API_TYPE.C919
getPart_ex_ARJ21_2.pdm_api_type = PDM_API_TYPE.ARJ21_2
getPart_ex_ARJ21_3.pdm_api_type = PDM_API_TYPE.ARJ21_3

const getPartMPR_C919 = getPartMPR
const getPartMPR_ARJ21_2 = getPartMPR
const getPartMPR_ARJ21_3 = getPartMPR
getPartMPR_C919.pdm_api_type = PDM_API_TYPE.C919
getPartMPR_ARJ21_2.pdm_api_type = PDM_API_TYPE.ARJ21_2
getPartMPR_ARJ21_3.pdm_api_type = PDM_API_TYPE.ARJ21_3


module.exports = {
  listPagedPart_C919, listPagedPart_ARJ21_2, listPagedPart_ARJ21_3,
  listPagedPartMPR_C919, listPagedPartMPR_ARJ21_2, listPagedPartMPR_ARJ21_3,
  getPart_C919, getPart_ARJ21_2, getPart_ARJ21_3,
  getPart_ex_C919, getPart_ex_ARJ21_2, getPart_ex_ARJ21_3,
  getPartMPR_C919, getPartMPR_ARJ21_2, getPartMPR_ARJ21_3,
}
